package com.changan.dao.impl;

import com.changan.dao.UserDao;
import com.changan.pojo.SmbmsUser;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("userDao")
public class UserDaoImpl extends HibernateDaoSupport implements UserDao{
    public UserDaoImpl(){

    }

    @Autowired
    public UserDaoImpl(@Qualifier("sessionFactory") SessionFactory sessionFactory){
        this.setSessionFactory(sessionFactory);
    }

    @Override
    public List<SmbmsUser> findUsers() {
        return this.getHibernateTemplate().find("from SmbmsUser");
    }
}
